package com.delu.mq;

import com.delu.entity.User;
import com.delu.feign.MessageFegin;
import com.delu.mapper.UserMapper;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = "returSuccess", consumerGroup = "retrunSuccess-group")
public class ReturnSuccessConsumer implements RocketMQListener<String> {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private MessageFegin messageFegin;

    @Override
    public void onMessage(String s) {

        User user = userMapper.selectById(Long.parseLong(s));

        messageFegin.sends(user.getPhone(), "还车成功");
    }
}
